package com.zyy.api.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * @author zhangyangyang
 * @createTime 2023414 14:23
 * @description 标签类型
 */
@Getter
@AllArgsConstructor
public enum LabelType {

    UNKNOWN("unknown", 0),
    TOPIC("主题标签", 1),
    STOCK("个股标签", 2),
    INDEX("指数标签", 3);

    private String description;

    //存在数据库里的最终type
    private int type;

    public static LabelType convert(int code) {
        return Stream.of(values())
            .filter(labelType -> labelType.type == code)
            .findFirst()
            .orElse(UNKNOWN);
    }


}
